
//====================================================================================================
// Filename:	WinMain.cpp
// Created by:	Ali Talhouni
// Description:	Bob & Weave
//====================================================================================================

//====================================================================================================
// Includes
//====================================================================================================

#include <SGE.h>
using namespace SGE;


#include "PlayState.h"
#include "FrontendState.h"


GameState * currentState = nullptr;
NextState nextState = Frontend;


//====================================================================================================
// SGE Functions
//====================================================================================================


void SGE_Initialize()
{
	
}

//----------------------------------------------------------------------------------------------------

void SGE_Terminate()
{
	
}

//----------------------------------------------------------------------------------------------------

bool SGE_Update(float deltaTime)
{
	if (nextState != None)
	{
		//Unload current State
		if (currentState!=nullptr)
		{
			currentState->Unload();
			delete currentState;
		}

		//change state
		switch (nextState)
		{
		case Frontend:
			currentState = new FrontendState();
			break;
		case Gameplay:
			currentState = new PlayState();
			break;
		}

		//load new state
		currentState->Load();
	}

	nextState= currentState->Update(deltaTime);

	if (nextState == Quit)
	{
		currentState->Unload();
		delete currentState;
		return true;
	}
	return false;
	
}

//----------------------------------------------------------------------------------------------------

void SGE_Render()
{
	currentState->Render();
}
